<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('布置实验')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="container">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <br>
    <br>
    <form class="form-horizontal m" id="form-experiment-edit" th:object="${experiment}">
        <input name="experimentId" th:field="*{experimentId}" type="hidden" id="experimentId">
        <div class="form-group">
            <label class="col-sm-3 control-label">实验名称：</label>
            <div class="col-sm-8">
                <input name="experimentName" id="experimentName" th:field="*{experimentName}"
                       class="form-control" type="text" required disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">开始时间：</label>
            <div class="col-sm-8">
                <input id="arrangeBeginDate" name="arrangeBeginDate"
                       class="form-control" type="text" placeholder="开始时间" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">结束时间：</label>
            <div class="col-sm-8">
                <input id="arrangeEndDate" name="arrangeEndDate"
                       class="form-control" type="text" placeholder="结束时间" required>
            </div>
        </div>
        <br>
    </form>
</div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js"/>
<th:block th:include="include :: datetimepicker-js" />
</body>
<script>
    var prefix=ctx+'/system/arrange';
    $("#arrangeBeginDate").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: 2,
        autoclose: true, //选择后自动关闭
        todayBtn: true,  //显示今天按钮
    })
    $("#arrangeEndDate").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: 2,
        autoclose: true, //选择后自动关闭
        todayBtn: true,  //显示今天按钮
    })


    $("#form-experiment-add").validate({
        focusCleanup: true
    });

    /*对学生所在实验*/
    function submitHandler() {
        $.modal.loading("正在提交请稍后");
        if ($.validate.form()) {
            if($("#arrangeBeginDate").val()>=$("#arrangeEndDate").val()){
                $.modal.alertError("请选择结束时间大于开始时间")
            }else{
                $.ajax({
                    url : prefix+'/arrangeAllStudents',
                    type: 'post',
                    data: {"arrangeExperimentId": $("#experimentId").val(),"arrangeBeginDate":$("#arrangeBeginDate").val(),"arrangeEndDate":$("#arrangeEndDate").val()},
                    dataType: 'json',
                    success:function (data) {
                        if(data.code==0){
                            $.modal.msgReload("布置成功",'success')
                        }
                        if(data.code==500){
                            $.modal.msgReload("布置失败",'error')
                        }
                    }
                })
            }
        }
    }
</script>
</html>